<template>
	<el-button @click="open">open</el-button>
</template>

<script setup lang="ts">
import { treeDrawer } from "@pkg";

const open = () => {
	treeDrawer
		.initTree(
			tree => {
				tree.setTreeSource([
					{
						label: "1",
						value: "",
						children: [
							{ label: "1.1", value: 1.1 },
							{ label: "1.2", value: 1.2 },
						],
					},
					{
						label: "2",
						value: 0,
						children: [
							{ label: "2.1", value: 2.1 },
							{ label: "2.2", value: 2.2 },
						],
					},
				]);
			},
			{ allowDisabling: false }
		)
		.initButton((btn, tree) => {
			btn.addButton({
				type: "info",
				name: "set",
				callback: () => {
					tree.setTreeSelection([1.1]);
				},
			});
			btn.addButton({
				type: "success",
				name: "Get",
				callback() {
					console.log(tree.getTreeSelection(), "gfet");
				},
			});
		})
		.open({
			title: "tree data",
		});
};
</script>

<style lang="scss" scoped></style>
